package com.bdmc.smokesensor.services;

import java.util.*;
import java.util.List;
import com.bdmc.smokesensor.dao.Rbac_ActionJPA;
import com.bdmc.smokesensor.entity.Rbac_Action;
import com.bdmc.smokesensor.iservices.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

@Service
public class Rbac_ActionService extends BaseService<Rbac_Action> implements IRbac_ActionService {

    @Autowired
    private Rbac_ActionJPA _funJPA;

    @Override
    public List<Rbac_Action> findAll() {
        List<Rbac_Action> list = _funJPA.findAll();
        return list;
    }

    @Override
    public Rbac_Action findOne(Example<Rbac_Action> example) {
        return _funJPA.findOne(example).orElse(null);
    }

    @Override
    public Rbac_Action findOneById(int id) {
        return _funJPA.findById(id).orElse(null);
    }

    @Override
    public Rbac_Action save(Rbac_Action d) {
        if (d.getId() < 1)
            d.setJoinDate(new Date());
        else
            d.setUpdateDate(new Date());
        return _funJPA.save(d);
    }

    @Override
    public void deleteById(int id) {
        _funJPA.deleteById(id);
    }

    @Override
    public List<Rbac_Action> GetByfunctionId(int f_id) {
        return _funJPA.findByRbacFunctionId(f_id);
    }

    @Override
    public List<Rbac_Action> getRoleActions(String ids) {
        return _funJPA.getRoleActions(ids);
    }
}